#include "ibmsgv_api.h"

#include "COM_ibp_test.dsc.h"

static int ibp_test_db( char *node )
{
	COM_ibp_test	req_st ;
	COM_ibp_test	rsp_st ;
	
	int		r = 0 ;
	
	memset( & req_st , 0x00 , sizeof(COM_ibp_test) );
	strcpy( req_st.account_no , "1234567890" );
	memset( & rsp_st , 0x00 , sizeof(COM_ibp_test) );
	r = IBMSGVCall_JSON( NULL , node , "ibp_test_db"
			, (void*) & req_st , & DSCSERIALIZE_JSON_DUP_COM_ibp_test_V
			, (void*) & rsp_st , & DSCDESERIALIZE_JSON_COM_ibp_test_V
			, NULL , NULL ) ;
	if( r )
	{
		printf( "IBMSGVCall failed[%d] , errno[%d]\n" , r , errno );
		return -1;
	}
	else
	{
		printf( "IBMSGVCall ok\n" );
	}
	
	printf( "response_code[%s] response_desc[%s] - account_no[%s] balance[%.2lf]\n"
		, rsp_st.response_code , rsp_st.response_desc
		, req_st.account_no , rsp_st.balance );
	
	return 0;
}

static void usage()
{
	printf( "USAGE : ibp_test_db node\n" );
	return;
}

int main( int argc , char *argv[] )
{
	int		nret = 0 ;
	
	if( argc == 1 + 1 )
	{
		IBPInitLogEnv( "" , "ibp_test_db" , "file::log/event.log" , LOG_LEVEL_DEBUG , "file::log/ibp_test_db.log" );
		nret = ibp_test_db( argv[1] ) ;
		IBPCleanLogEnv();
		return -nret;
	}
	else
	{
		usage();
		exit(7);
	}
}

